home *** CD-ROM | disk | FTP | other *** search
- Path: news2.ios.com!usenet
- From: vlad@gramercy.ios.com (Vlastimil Adamovsky)
- Newsgroups: comp.lang.c++
- Subject: Re: Using MFC with C
- Date: Fri, 02 Feb 1996 14:49:16 GMT
- Organization: Internet Online Services
- Message-ID: <4et7o1$1ur@news2.ios.com>
- References: <4ek2gh$t26@news1.usa.pipeline.com>
- NNTP-Posting-Host: ppp-38.ts-7.hck.idt.net
- X-Newsreader: Forte Free Agent 1.0.82
-
- grantp@usa.pipeline.com(Pete) wrote:
- >There's no (reasonable) way to call C++ class member functions
- >directly from C. You need to write an API layer for the C++ module.
- >If you're passing pointers to C++ classes to the C side, then you can
- >do something like this:
- >
- >int FooApi (void * object, int arg)
- > {
- > FooClass * p = (FooClass*)object;
- > return p->Foo(arg);
- > }
- >
- >Of course, the two lines can be combined; I just thought it might
- >be clearer when split into two.
- >>
-
- There could be also another possiblity:
-
- Take the C code, and if necessary declare all C functions as extern
- "C" in the header. Include C++ header for objects you want to call and
- compile everything as a C++. Then you are able to call C++ member
- functions from within C functions. Though overloaded functions will
- not compile.
- *******************************************
- * Vlastimil Adamovsky *
- * Smalltalk, C++ and Envelop development *
- *******************************************
-
-